import API_URL from './url'
import useHttpInstance from './useHttp'
import useESHttpInstance from './useESHttp'

const request = useHttpInstance()
const esRequest = useESHttpInstance()
// 账号登录
export function login(username, password) {
  return request.post('/api/user/login', { username, password })
}
// 手机号登录
export function phoneLogin(params) {
  return request.post('/api/user/login_with_code', params)
}

// 发送验证码
export function sendCode(params) {
  return request.post('/api/user/send_code', params)
}
// 注册
export function register(params) {
  return request.post('/api/user/register_with_code', params)
}
// 忘记密码
export function GetForgotPassword(params) {
  return request.post('/api/user/forget_password', params)
}

export function GetOfficeInfo() {
  return request.get('/api/return_AppInfo')
}

// 获取用户信息
export function getUserInfo() {
  return request.get('/api/user/current_user')
}

// export function getHistoryChatList() {
// 	return request.get(API_URL.CHAT_HISTORY);
// }
// 暂停输出

export function stopOutput() {
  return request.get('/api/stop_output')
}

// 常见内容
export function getSimilarProblems() {
  return request.get('/api/get_similar_problems')
}
export function listenerAdviserMsg(data, callback, api) {
  console.log('data=====', data)
  return esRequest.post(api ? API_URL[api] : API_URL.ADVISER_CHAT, data, {
    onmessage: callback
  })
}

// 常见问题
// frequentlyAskedQuestions
export function frequentlyAskedQuestions(params) {
  return request.post('/api/get_similar_problems_content', params)
}

export function uploadFile(formData, uploadProcess) {
  return request.post('/api/upload_contract_file', formData, {
    onUploadProgress: (progressEvent) => {
      let percent = ((progressEvent.loaded / progressEvent.total) * 100) | 0
      uploadProcess && uploadProcess(percent)
    }
  })
}

// 上传文件列表
export function getContractFileList(params) {
  return request.get('/api/get_contract_file_list', params)
}

// 获取聊天历史记录
export function getChatHistory(params) {
  return request.get('/api/get_history_chat_list', params)
}

// 聊天内容历史记录
export function getHistoryChatContent(id, page_number, page_size) {
  return request.post('/api/get_history_chat_content', { id, page_number, page_size })
}

// 审查立场列表
export function GetreviewTheListOfPositions(params) {
  return request.get('/api/get_contract_stance_list', params)
}
// 合同类型
export function GetTypeOfContract(params) {
  return request.get('/api/get_contract_type_list', params)
}
// 文件审查规则
export function getContractreviewRules(params) {
  return request.post('/api/get_contract_rule', params)
}
// 开始审查
export function StartTheReview(params) {
  // return request.post('/api/contract_review', params);
  return request.post('/api/contract_review', params)
}

// 财务报表历史记录
export function GetFinancialStatementHistory(params) {
  return request.get('/api/get_financial_statement_analysis_history', params)
}
// 财务报表分析文件上传
export function UploadFinance(formData, uploadProcess) {
  return request.post('/api/upload_financial_statement', formData, {
    onUploadProgress: (progressEvent) => {
      let percent = ((progressEvent.loaded / progressEvent.total) * 100) | 0
      uploadProcess && uploadProcess(percent)
    }
  })
}

// 会计准则
export function accountingStandards(params) {
  return request.get('/api/get_accounting_standards_list', params)
}
// 会计报表类型
export function theTypeOfAccountingReport(params) {
  return request.get('/api/get_report_type_list', params)
}
export function GetAllFile() {
  return request.get('/api/get_financial_statement_list')
}

// 勾选的分析列表

export function GetCheckFileList(params) {
  return request.post('/api/get_selected_financial_statement_list', params)
}

// 流式输出分析结果
export function chartAnalyzeTheResults(data, callback) {
  return esRequest.post('/api/analyze_financial_statement', data, {
    onmessage: callback
  })
}

// 流式输出分析结果
export function GetHistoryListOfAnaly(params) {
  return request.get('/api/get_financial_statement_analysis_history', params)
}

// 纳税申报历史记录
export function taxReturnHistory(params) {
  return request.get('/api/get_tax_filing_analysis_history', params)
}

// 纳税分析报表
export function chartAnalyzeTheRatepaying(data, callback) {
  console.log('data=====', data)
  return esRequest.post('/api/analyze_tax_filing', data, {
    onmessage: callback
  })
}

// 文书生成历史记录
export function documentGenerationHistory(params) {
  return request.get('/api/get_contract_documents_list', params)
}
// 获取类型列表
export function getAListOfTypes(params) {
  return request.get('/api/get_type_list', params)
}
// 获取具体类型列表
export function getAListOfSpecificTypes(params) {
  return request.post('/api/get_subtype_list', params)
}
// 合同生成文书
export function generatePapers(data, callback) {
  return esRequest.post(
    '/api/generate_contract',
    { ...data },
    {
      onmessage: callback
    }
  )
}
// 转化成docx
export function invertDocx(params) {
  return request.post('/api/save_contract_document', params)
}
// 获取下载地址
export function getTheDownloadAddress(params) {
  return request.post('/api/download_contract_document', params)
}
// 获取审查结果
export function getTheTheReview(params) {
  return request.post('/api/get_review_result', params)
}
//  获取纳税历史记录
export function getYourTaxHistory(params) {
  return request.get('/api/get_tax_filing_analysis_history', params)
}

// 进出口退税查询

export function drawbackSearch(params) {
  return request.post('/api/tax_rebate/fuzzy_query', params)
}

// 进出口商品编码

export function GetProjectCode(params) {
  return request.get('/api/tax_rebate/get_hscode_tree', params)
}

// 进口税费计算
export function importAnalyse(params) {
  return request.post('/api/tax_rebate/import_tax_analysis', params)
}

// 获取名称
export function getHscodeProductName(params) {
  return request.post('/api/tax_rebate/get_hscode_product_name', params)
}

// 出口税费分析
export function outletAnalyse(params) {
  return request.post('/api/tax_rebate/export_tax_analysis', params)
}

// 财务报表删除
export function deleteReport(params) {
  return request.post('/api/delete_uploaded_file', params)
}

// 退税收藏

export function taxRefundCollection(params) {
  return request.post('/api/tax_rebate/collect', params)
}
export function collectionList(params) {
  return request.get('/api/tax_rebate/get_history', params)
}

// 下载页面

export function getDownLoadList(params) {
  return request.get('/api/tax_rebate/get_custom_doc_templates', params)
}

// 人工咨询提交

export function humanConsultation(params) {
  return request.post('/api/apply_expert_service', params)
}

// 获取服务模块
export function GetTheServiceModule(params) {
  return request.get('/api/get_service_module_list', params)
}

// export function getResearchFileList() {
// 	return request.get(API_URL.RESEARCH_FILE_LIST);
// }

// export function getAIAssistRead(id) {
// 	return request.post(API_URL.RESEARCH_CHAT_CONTENT, { id });
// }

// export function newsSetSelect(labels) {
// 	return request.post(API_URL.NEWS_SET_SELECT, { labels });
// }

// export function getNewsLabel() {
// 	return request.get(API_URL.NEWS_LABEL);
// }

// export function getUserNewsLabel() {
// 	return request.get(API_URL.USER_NEWS_LABEL);
// }

// export function getNewsList(page_number, page_size, search) {
// 	return request.post(API_URL.NEWS_LIST, { page_number, page_size, search });
// }

// export function dailyNewsSetSelect(data) {
// 	return request.post(API_URL.DAILY_NEWS_SET_SELECT, data);
// }

// export function getDailyNewsList(page_number, page_size) {
// 	return request.post(API_URL.DAILY_NEWS_LIST, { page_number, page_size });
// }
// export function getDailyNewsDetail(id) {
// 	return request.post(API_URL.DAILY_NEWS_DETAIL, { id });
// }

// export function getDailyNewsLabel(){
//     return request.get(API_URL.DAILY_NEWS_LABEL);
// }

// export function getUserDailyNewsLabel(){
//     return request.get(API_URL.USER_DAILY_NEWS_LABEL);
// }

// export function listenerResearchMsg(data, callback) {
//     return esRequest.post(API_URL.RESEARCH_CHAT, data, {
//         onmessage: callback
//     });
// }

// export function listenerNewsMsg(data, callback) {
//     return esRequest.post(API_URL.NEWS_CHAT, data, {
//         onmessage: callback
//     });
// }

// export function listenerDailyNewsMsg(data, callback) {
//     return esRequest.post(API_URL.DAILY_NEWS_CHAT, data, {
//         onmessage: callback
//     });
// }
